package com.china08.yxyapi.api.comm;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.db.res.YxyResFormat;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.repository.db.YxyResFormatRepository;

import io.swagger.annotations.ApiOperation;

@CrossOrigin
@RestController
public class FormatAllController extends YxyApiBaseController {

    @Autowired
    private YxyResFormatRepository yrfr;

    @ApiOperation(value = "获得格式")
    @RequestMapping(value = "/api_yw/comm/format/all", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<RespModel> find() {
        List<YxyResFormat> formats = new ArrayList<YxyResFormat>();
        List<String> aList = new ArrayList<String>();
        aList.add("FMT06");
        aList.add("FMT07");
        List<RespModel> list = new ArrayList<FormatAllController.RespModel>();
        formats = yrfr.findByIdNotInAndStatusOrderByOrderNum(aList,1);
        for (YxyResFormat format : formats) {
            RespModel model = new RespModel();
            model.id = format.getId();
            model.name = format.getName();
            list.add(model);
        }
        return list;
    }

    protected static class RespModel extends YxyApiReqModel {
        public String id;
        public String name;
    }

}
